return ret;
}
-function _getCalendarWeekForDate(date) {
- // Based on the algorithms found here:
- // http://en.wikipedia.org/wiki/Talk:ISO_week_date
- let midnightDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
- // Need to get Monday to be 1 ... Sunday to be 7
- let dayOfWeek = 1 + ((midnightDate.getDay() + 6) % 7);
- let nearestThursday = new Date(midnightDate.getFullYear(), midnightDate.getMonth(),
- midnightDate.getDate() + (4 - dayOfWeek));
-
- let jan1st = new Date(nearestThursday.getFullYear(), 0, 1);
- let diffDate = nearestThursday - jan1st;
- let dayNumber = Math.floor(Math.abs(diffDate) / MSECS_IN_DAY);
- let weekNumber = Math.floor(dayNumber / 7) + 1;
-
- return weekNumber;
-}
-
function _getCalendarDayAbbreviation(dayNumber) {
let abbreviations = [
/* Translators: Calendar grid abbreviation for Sunday.
this._buttons.push(button);
if (this._useWeekdate && iter.getDay() == 4) {
- let label = new St.Label({ text: _getCalendarWeekForDate(iter).toString(),
+ let label = new St.Label({ text: iter.toLocaleFormat('%V'),
style_class: 'calendar-day-base calendar-week-number'});
layout.attach(label, rtl ? 7 : 0, row, 1, 1);
}